package com.kaibes.core.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class NotBlankButNullValidator implements ConstraintValidator<NotBlankButNull, String> {
    
    @Override
    public void initialize(NotBlankButNull constraintAnnotation) {
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value != null) {
            return !value.trim().isEmpty();
        } else {
            return true;
        }
    }

}
